import type { Router } from 'vue-router';
import { setRouteEmitter } from '@/utils/route-listener';
import setupUserLoginInfoGuard from './userLoginInfo';
import setupPermissionGuard from './permission';

function setupPageGuard(router: Router) {
  router.beforeEach(async (to) => {
    setRouteEmitter(to);
  });
}

// 创建路由守卫
export default function createRouteGuard(router: Router) {
  // 安装页面守卫
  setupPageGuard(router);
  // 安装用户登录守卫
  setupUserLoginInfoGuard(router);
  // 安装权限守卫
  setupPermissionGuard(router);
}
